<?php echo $this->Session->flash(); ?>
<h1>PLANOS DEL PREDIO <?php echo$cod; ?></h1>
<div id="loading" style="display: none;">
    <?php echo $html->image('loading.gif', array('border' => "0", 'align' => 'center')); ?>
</div>
<?php foreach ($properties as $prop): ?>
    <table  id="tabla" id="tabla" >
        <thead>
            <tr>
                <th></th>
                <th>Área en el mapa (ha)</th>
                <th>Suma de áreas parciales (ha)</th>
                <th>Calificación</th>
                <th>Observación</th>
                <th colspan="1"></th>
            </tr>
        </thead>
        <tbody>
            <?php
            App::Import('model', 'TopographicArea');
            $tArea = new TopographicArea();
            $res = $tArea->find('first', array('fields' => array('SUM(TopographicArea.magnitud) AS suma'), 'conditions' => array('TopographicArea.topographic_map_id' => $prop['TopographicMap']['id'])));
            ?>
            <tr>
                <td>
                    <table>
                        <tr><td>Departamento</td><td><?php echo $prop['Departament']['name'] ?></td> </tr>
                        <tr><td>Vereda</td><td><?php echo $prop['TopographicMap']['vereda'] ?></td> </tr>
                        <tr><td>Municipio</td><td><?php echo $prop['City']['name'] ?></td> </tr>
                    </table>
                </td>
                <td><?php echo number_format($prop['TopographicMap']['area'], 4, ',', '.') ?></td>
                <td><?php echo number_format($res[0]['suma'], 4, ',', '.') ?></td>
                <td><?php
        if ($prop['TopographicMap']['calificacion'] == 0) {
            echo "Sin registro";
        } else if ($prop['TopographicMap']['calificacion'] == 1) {
            echo "Cumple";
        } else if ($prop['TopographicMap']['calificacion'] == 2) {
            echo "Subsanable";
        } else {
            echo "No cumple";
        }
            ?></td>
                <td><?php echo $prop['TopographicMap']['observacion'] ?></td>
                <td>
                    <?php echo $ajax->link('Áreas', array('controller' => 'TopographicAreas', 'action' => 'index', $prop['TopographicMap']['id'], $property_id), array('class' => 'actions', 'update' => 'content', 'complete' => 'cargar()', 'indicator' => 'loading', 'escape' => false)); ?>
                    <br><br>
                    <?php echo $ajax->link('Editar', array('controller' => 'TopographicMaps', 'action' => 'edit', $prop['TopographicMap']['id']), array('class' => 'actions', 'update' => 'content', 'complete' => 'cargar()', 'indicator' => 'loading', 'escape' => false)); ?>
                </td>
            </tr>
        </tbody>
    </table>
    <br><br><br>
<?php endforeach; ?>



<table width="100%" border="0"  CellSpacing=10  align="center" >
    <tbody>
        <tr>
            <td><?php echo $ajax->link('Adicionar', array('controller' => 'TopographicMaps', 'action' => 'add', $property_id), array('class' => 'actions', 'update' => 'content', 'complete' => 'cargar()', 'indicator' => 'loading', 'escape' => false)); ?></td>
            <td><?php echo $ajax->link($html->image('regresar.gif', array('width' => '30', 'heigth' => '30', 'alt' => 'Regresar', 'title' => 'regresar')), array('controller' => 'properties', 'action' => 'index_topographic_map'), array('update' => 'content', 'complete' => 'cargar()', 'indicator' => 'loading', 'escape' => false)); ?></td>
        </tr>
    </tbody>
</table>

